import 'package:flutter/material.dart';
import 'package:vmall_app/pages/detail/goods_detail.dart';

class GoodsList extends StatefulWidget {
  final String categoryName;

  const GoodsList({Key key, this.categoryName}) : super(key: key);

  @override
  _GoodsListState createState() => _GoodsListState();
}

class _GoodsListState extends State<GoodsList> {
  @override
  Widget build(BuildContext context) {
    return Container(); // Container(color: Colors.white, child: Column(children: goodsCards));
  }
}

class GoodsCard extends StatelessWidget {
  final int goodsId;
  final String imageUrl;
  final String name;
  final double price;
  final double discountPrice;
  final int buyCount;
  final String description;

  const GoodsCard(
      {Key key,
      this.imageUrl,
      this.name,
      this.price,
      this.discountPrice,
      this.buyCount,
      this.goodsId,
      this.description = ""})
      : super(key: key);
  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: () {
        Navigator.of(context).push(MaterialPageRoute(builder: (context) {
          return GoodsDetail(goodsId: this.goodsId);
        }));
      },
      child: Container(
        padding: const EdgeInsets.all(5),
        child: Column(
          children: <Widget>[
            ClipRRect(
              borderRadius: BorderRadius.circular(5),
              child: Image.network(
                imageUrl,
                fit: BoxFit.fill,
              ),
            ),
            Container(
              decoration: BoxDecoration(
                  color: Colors.white60,
                  borderRadius: BorderRadius.only(
                      bottomLeft: Radius.circular(5),
                      bottomRight: Radius.circular(5))),
              child: Column(
                children: <Widget>[
                  Padding(
                    padding: const EdgeInsets.all(8.0),
                    child: Text(
                      name,
                      style: TextStyle(fontSize: 13),
                    ),
                  ),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceAround,
                    children: <Widget>[
                      Text(
                        price.toString(),
                        style: TextStyle(color: Colors.red),
                      ),
                      Text(
                        "${buyCount.toString()}人付款",
                        style: TextStyle(color: Colors.grey, fontSize: 12),
                      ),
                      Icon(
                        Icons.more_horiz,
                        size: 20,
                        color: Colors.grey,
                      )
                    ],
                  )
                ],
              ),
            )
          ],
        ),
      ),
    );
  }
}
